#include <stdio.h>
extern "C"
{
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
}

static int add(lua_State *L)
{
    int a, b, c;
    a = lua_tonumber(L, 1);
    b = lua_tonumber(L, 2);
    c = a + b;
    lua_pushnumber(L, c);
    printf("test hello!!!\r\n");
    return 1;
}

static const struct luaL_Reg lib[] = {
    {"testadd", add},
    {NULL, NULL}
};

// extern "C"不可以忽略
// 此函数名跟此so文件名固定且so不能带前缀 不可修改custom
extern "C" int luaopen_custom(lua_State *L)
{
    luaL_newlib(L, lib);
    return 1;
}
